<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ESLint的使用</title>
</head>
<body>
    <h1>ESLint的使用</h1>

    <script>
        // ESLint配置示例
        /*
        {
            "env": {
                "es6": true,
                "browser": true,
                "node": true
            },
            "extends": "eslint:recommended",
            "rules": {
                // 禁止使用var
                "no-var": "error",
                
                // 优先使用const
                "prefer-const": "error",
                
                // 强制使用单引号
                "quotes": ["error", "single"],
                
                // 强制使用分号
                "semi": ["error", "always"],
                
                // 箭头函数参数必须使用括号
                "arrow-parens": ["error", "always"]
            }
        }
        */

        // 符合ESLint规范的代码示例
        const PI = 3.14159;
        
        const calculateArea = (radius) => {
            return PI * radius * radius;
        };

        const logResult = (value) => {
            console.log(`结果是: ${value}`);
        };

        const radius = 5;
        const area = calculateArea(radius);
        logResult(area);

        // 类的定义
        class Rectangle {
            constructor(width, height) {
                this.width = width;
                this.height = height;
            }

            getArea() {
                return this.width * this.height;
            }
        }

        // 数组方法
        const numbers = [1, 2, 3, 4, 5];
        const doubled = numbers.map((num) => num * 2);
        const sum = numbers.reduce((acc, curr) => acc + curr, 0);
    </script>
</body>
</html> 